#pragma once

static void DrawRoundRect(Gdiplus::Graphics& graphics, Gdiplus::Pen& pen, Gdiplus::Rect rect, 
				   int nPercentageRounded, Gdiplus::Brush* pBrush = NULL)
{
	ASSERT (nPercentageRounded >= 1 && nPercentageRounded <= 100);

	int left  = min(rect.GetLeft(), rect.GetRight());
	int right = max(rect.GetLeft(), rect.GetRight());

	int top    = min(rect.GetTop(), rect.GetBottom());
	int bottom = max(rect.GetTop(), rect.GetBottom());

	int offsetX = (right-left) * nPercentageRounded / 100;  
	int offsetY = (bottom-top) * nPercentageRounded / 100;

	Gdiplus::GraphicsPath path;
	path.AddArc(right - offsetX, top, offsetX, offsetY, 270, 90);
	path.AddArc(right - offsetX, bottom - offsetY, offsetX, offsetY, 0, 90);
	path.AddArc(left, bottom - offsetY, offsetX, offsetY, 90, 90);
	path.AddArc(left, top, offsetX, offsetY, 180, 90);
	path.AddLine(left + offsetX, top, right - offsetX / 2, top);

	if(pBrush != NULL)
		graphics.FillPath(pBrush, &path);

	graphics.DrawPath(&pen, &path);
}